"""Created the 2013-08-25 14:33 

@author:
"""
import sys

from libatomism import *
from PySide import QtCore, QtGui
from msWidget import *
from msGeneralizedCoordinatesWidget import *
from msScalarVariableWidget import *

class msKineticOperatorWidget(msWidget):
    """
    graphical component for msZMat
    """
    """
    def __init__(self, objectdb, mainwindow):
        super(msKineticOperatorWidget, self).__init__(objectdb,mainwindow)

        self.vbox.addWidget(msGeneralizedCoordinatesWidget(self.data.getCoordinates(),self.mainwindows) )

        self.setMinimumWidth(450)
        self.setMaximumWidth(450)
    """
    def __init__(self, objectdb, mainwindow):
        super(msKineticOperatorWidget, self).__init__(objectdb,mainwindow)

        self.listView = QtGui.QTreeView()
        self.listView.clicked.connect(self.clickListView)
        model = VariablesTreeModel(self.data.getChild("GeneralizedCoordinates"),self)
        self.listView.setModel(model)   
        self.hbox = QtGui.QHBoxLayout()
        self.hbox.addWidget(self.listView)
        self.vbox.addLayout(self.hbox)
        self.setMinimumHeight( 170)
        self.setMaximumHeight(170)
        
        self.setMinimumWidth(450)
        self.setMaximumWidth(450)
        self.widgetScalVar = msScalarVariableWidget(self.data.getCoordinates().getVariable(0) ,self.mainwindows)


    def clickListView(self):
        self.widgetScalVar.data = self.listView.currentIndex().internalPointer().getRawdata()
        self.widgetScalVar.updateCoordinate( )
        self.widgetScalVar.slider.valueChanged[int].connect(self.updateListView)
        self.widgetScalVar.valueSpinBox.valueChanged[float].connect(self.updateListView)
        self.hbox.addWidget(self.widgetScalVar)

    def updateListView(self):
        model = VariablesTreeModel(self.data.getCoordinates(),self)
        self.listView.setModel(model)          

